package com.mcm.lstudy.dao.impl;

import java.util.List;

import com.mcm.lstudy.entity.User_Course;
import com.mcm.lstudy.tools.DBTools;

public class User_CourseDaoImpl implements com.mcm.lstudy.dao.User_CourseDao {

	@Override
	public boolean addUserCourse(User_Course uc) {
		String sql = "insert into user_course values(?,?)";
		return DBTools.exUpdate(sql, uc.getUid(),uc.getCid())>0;
	}

	@Override
	public boolean delUserCourse(User_Course uc) {
		String sql = "delete from user_course where uid = ? and cid =?";
		return DBTools.exUpdate(sql, uc.getUid(),uc.getCid())>0;
	}

	@Override
	public List<User_Course> getCidByUid(int uid) {
		String sql = "select * from user_course where uid = ?";
		List<User_Course> li = (List<User_Course>) DBTools.exQuery(sql, User_Course.class, uid);
		return li;
	}

	@Override
	public List<User_Course> getUidByCid(int cid) {
		String sql = "select * from user_course where cid = ?";
		List<User_Course> li = (List<User_Course>) DBTools.exQuery(sql, User_Course.class, cid);
		return li;
	}

}
